﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace GFC
{
    [Serializable]
    [XmlInclude(typeof(FieldDependantField))]
    [XmlInclude(typeof(ValueDependantField))]
    public abstract class ConditionalField : Field
    {
        private string m_DependancyFieldName;

        protected ConditionalField()
        {
        }

        public ConditionalField(Frame frame, string name, int size, FieldType type, string dependancyFieldName) :
            base(frame, name, size, type)
        {
            this.m_DependancyFieldName = dependancyFieldName;
        }

        public string DependancyFieldName
        {
            get { return m_DependancyFieldName; }
        }

        public override bool Equals(object obj)
        {
            ConditionalField field = obj as ConditionalField;
            if (field == null)
                return false;
            return base.Equals(obj) && this.DependancyFieldName == field.DependancyFieldName;
        }
    }
}
